//################################
// 版权所有：鸽子游戏俱乐部
// 系统名称：鸽子游戏俱乐部-移动版
// 文件名称：mycenterService.js
// 创建时间：2017年04月22日
// 创建人员：Lemo
// 功能说明：个人中心service
//################################
'use strict';

import Config from '../common/config';
import CommonFunc from '../common/commonFunc';
import { request } from '../utils/requestUtil';
import UIConstants from '../common/uiconstants';

function getRentGamesList(userId){
    return new Promise((resolve, reject) => {
        /*var result = {
                "pageResult":{"totalPageCount":0},
                "data":[
                    {
                        "GameName": "GTA5侠盗猎车手5",
                        "ExpressCom": "韵达",
                        "ExpressNum": "12212122132",
                        "GzCoin":"38",
                        "Time":"2017-06-23 12:37:25"
                    },{
                        "GameName": "红色警戒共和国之辉2",
                        "ExpressCom": "韵达",
                        "ExpressNum": "12212122132",
                        "GzCoin":"38",
                        "Time":"2017-06-23 12:37:25"
                    },{
                        "GameName": "GTA5侠盗猎车手5",
                        "ExpressCom": "韵达",
                        "ExpressNum": "12212122132",
                        "GzCoin":"38",
                        "Time":"2017-06-23 12:37:25"
                    }],
                "info": "2017-04-27 23:26:15",
        };
        resolve(result);*/
        
        var requestUrl = CommonFunc.getUrlConfig('getRentGamesUrl','mycenter');

        let params = {};
        params.timeout = 3000;
        params.method = 'get';
        params.url = requestUrl;
    
        request(params)
        .then((responseData) => {
            if (responseData.code=='200') {
                resolve(responseData);
            }
            else {
                var result = {
                    code: responseData.code,
                    message: responseData.message,
                };
                reject(result);
            }
        })
        .catch((error) => {
            reject(error);
        });
    });
}

function getReturnGamesList(userId){
    return new Promise((resolve, reject) => {
        var result = {
                "pageResult":{"totalPageCount":0},
                "code":"200",
                "data":[
                    {
                        "GameName": "GTA5侠盗猎车手5",
                        "ExpressCom": "韵达",
                        "ExpressNum": "12212122132",
                        "GzCoin":"38",
                        "Time":"2017-06-23 12:37:25"
                    },{
                        "GameName": "红色警戒共和国之辉2",
                        "ExpressCom": "韵达",
                        "ExpressNum": "12212122132",
                        "GzCoin":"38",
                        "Time":"2017-06-23 12:37:25"
                    },{
                        "GameName": "GTA5侠盗猎车手5",
                        "ExpressCom": "韵达",
                        "ExpressNum": "12212122132",
                        "GzCoin":"38",
                        "Time":"2017-06-23 12:37:25"
                    }],
                "info": "2017-04-27 23:26:15",
        };
        resolve(result);
        
    });
}

function getFundHistory(userId, page, pagenum) {
    return new Promise((resolve, reject) => {
        var result = {
                "pageResult":{"totalPageCount":1},
                "data":[
                    {
                        "date": "2017-05-01 10:21:14",
                        "num": "30",
                        "type": "付款",
                        "content": "PS4 神秘海域4"
                    },{
                        "date": "2017-05-02 12:21:14",
                        "num": "100",
                        "type": "充值",
                        "content": "淘宝"
                    },{
                        "date": "2017-06-01 10:21:14",
                        "num": "30",
                        "type": "付款",
                        "content": "PS4 最终幻想15"
                    }],
                "stringData": null,
                "message": null,
                "detail": null,
                "success": true,
                "status": "0000"
        };
        resolve(result);
        
    });
}

module.exports = {
    getRentGamesList,
    getReturnGamesList,
    getFundHistory,
}